#include <iostream>
using namespace std;
int main()
{
	int n;
	cin >> n;
	while(n--)
	{
		char c;
		cin >> c;
		double d;
		cin >> d;
		if(c == 'M')
			printf("%.2f\n", d/1.09);
		else
			printf("%.2f\n", d * 1.09);
	}
	return 0;
}